home *** CD-ROM | disk | FTP | other *** search
/ Micromanía: 150 Juegos 2010 / 150Juegos_16.iso / Shareware / Shape Smash / shape-smash.swf / scripts / Box2D / Dynamics / _tn475.as < prev    next >
Encoding:
Text File  |  2010-05-14  |  11.7 KB  |  362 lines

  1. package Box2D.Dynamics
  2. {
  3.    import Box2D.Collision._cc280;
  4.    import Box2D.Collision._kn203;
  5.    import Box2D.Common.Math._oh327;
  6.    import Box2D.Common.Math._ui293;
  7.    import Box2D.Common.Math.b2Vec2;
  8.    import Box2D.Common._kc225;
  9.    import Box2D.Dynamics.Contacts._dm217;
  10.    import Box2D.Dynamics.Contacts._kg776;
  11.    import Box2D.Dynamics.Contacts._lj358;
  12.    import Box2D.Dynamics.Contacts._nb823;
  13.    import Box2D.Dynamics.Contacts._wf486;
  14.    import Box2D.Dynamics.Joints._yw701;
  15.    
  16.    public class _tn475
  17.    {
  18.       private static var s_reportCR:_wf486 = new _wf486();
  19.       
  20.       public var m_listener:_nu737;
  21.       
  22.       public var m_positionIterationCount:int;
  23.       
  24.       public var m_bodyCapacity:int;
  25.       
  26.       public var m_bodies:Array;
  27.       
  28.       public var m_bodyCount:int;
  29.       
  30.       public var m_contactCapacity:int;
  31.       
  32.       public var m_jointCapacity:int;
  33.       
  34.       public var m_contactCount:int;
  35.       
  36.       public var m_contacts:Array;
  37.       
  38.       public var m_jointCount:int;
  39.       
  40.       public var m_allocator:*;
  41.       
  42.       public var m_joints:Array;
  43.       
  44.       public function _tn475(param1:int, param2:int, param3:int, param4:*, param5:_nu737)
  45.       {
  46.          var _loc6_:int = 0;
  47.          super();
  48.          m_bodyCapacity = param1;
  49.          m_contactCapacity = param2;
  50.          m_jointCapacity = param3;
  51.          m_bodyCount = 0;
  52.          m_contactCount = 0;
  53.          m_jointCount = 0;
  54.          m_allocator = param4;
  55.          m_listener = param5;
  56.          m_bodies = new Array(param1);
  57.          _loc6_ = 0;
  58.          while(_loc6_ < param1)
  59.          {
  60.             m_bodies[_loc6_] = null;
  61.             _loc6_++;
  62.          }
  63.          m_contacts = new Array(param2);
  64.          _loc6_ = 0;
  65.          while(_loc6_ < param2)
  66.          {
  67.             m_contacts[_loc6_] = null;
  68.             _loc6_++;
  69.          }
  70.          m_joints = new Array(param3);
  71.          _loc6_ = 0;
  72.          while(_loc6_ < param3)
  73.          {
  74.             m_joints[_loc6_] = null;
  75.             _loc6_++;
  76.          }
  77.          m_positionIterationCount = 0;
  78.       }
  79.       
  80.       public function _eq278(param1:_ut97, param2:b2Vec2, param3:Boolean, param4:Boolean) : void
  81.       {
  82.          var _loc5_:int = 0;
  83.          var _loc6_:_th791 = null;
  84.          var _loc7_:_yw701 = null;
  85.          var _loc8_:_kg776 = null;
  86.          var _loc9_:int = 0;
  87.          var _loc10_:Boolean = false;
  88.          var _loc11_:Boolean = false;
  89.          var _loc12_:Boolean = false;
  90.          var _loc13_:Number = NaN;
  91.          var _loc14_:Number = NaN;
  92.          var _loc15_:Number = NaN;
  93.          _loc5_ = 0;
  94.          while(_loc5_ < m_bodyCount)
  95.          {
  96.             _loc6_ = m_bodies[_loc5_];
  97.             if(!_loc6_._ur192())
  98.             {
  99.                _loc6_.m_linearVelocity.x += param1.dt * (param2.x + _loc6_.m_invMass * _loc6_.m_force.x);
  100.                _loc6_.m_linearVelocity.y += param1.dt * (param2.y + _loc6_.m_invMass * _loc6_.m_force.y);
  101.                _loc6_.m_angularVelocity += param1.dt * _loc6_.m_invI * _loc6_.m_torque;
  102.                _loc6_.m_force._he34();
  103.                _loc6_.m_torque = 0;
  104.                _loc6_.m_linearVelocity._bx376(_ui293._mx500(1 - param1.dt * _loc6_.m_linearDamping,0,1));
  105.                _loc6_.m_angularVelocity *= _ui293._mx500(1 - param1.dt * _loc6_.m_angularDamping,0,1);
  106.                if(_loc6_.m_linearVelocity._rq734() > _kc225.b2_maxLinearVelocitySquared)
  107.                {
  108.                   _loc6_.m_linearVelocity._qi627();
  109.                   _loc6_.m_linearVelocity.x *= _kc225.b2_maxLinearVelocity;
  110.                   _loc6_.m_linearVelocity.y *= _kc225.b2_maxLinearVelocity;
  111.                }
  112.                if(_loc6_.m_angularVelocity * _loc6_.m_angularVelocity > _kc225.b2_maxAngularVelocitySquared)
  113.                {
  114.                   if(_loc6_.m_angularVelocity < 0)
  115.                   {
  116.                      _loc6_.m_angularVelocity = -_kc225.b2_maxAngularVelocity;
  117.                   }
  118.                   else
  119.                   {
  120.                      _loc6_.m_angularVelocity = _kc225.b2_maxAngularVelocity;
  121.                   }
  122.                }
  123.             }
  124.             _loc5_++;
  125.          }
  126.          _loc8_ = new _kg776(param1,m_contacts,m_contactCount,m_allocator);
  127.          _loc8_._mf779(param1);
  128.          _loc5_ = 0;
  129.          while(_loc5_ < m_jointCount)
  130.          {
  131.             _loc7_ = m_joints[_loc5_];
  132.             _loc7_._mf779(param1);
  133.             _loc5_++;
  134.          }
  135.          _loc5_ = 0;
  136.          while(_loc5_ < param1.maxIterations)
  137.          {
  138.             _loc8_._md397();
  139.             _loc9_ = 0;
  140.             while(_loc9_ < m_jointCount)
  141.             {
  142.                _loc7_ = m_joints[_loc9_];
  143.                _loc7_._md397(param1);
  144.                _loc9_++;
  145.             }
  146.             _loc5_++;
  147.          }
  148.          _loc8_._wm59();
  149.          _loc5_ = 0;
  150.          while(_loc5_ < m_bodyCount)
  151.          {
  152.             _loc6_ = m_bodies[_loc5_];
  153.             if(!_loc6_._ur192())
  154.             {
  155.                _loc6_.m_sweep.c0._kh737(_loc6_.m_sweep.c);
  156.                _loc6_.m_sweep.a0 = _loc6_.m_sweep.a;
  157.                _loc6_.m_sweep.c.x += param1.dt * _loc6_.m_linearVelocity.x;
  158.                _loc6_.m_sweep.c.y += param1.dt * _loc6_.m_linearVelocity.y;
  159.                _loc6_.m_sweep.a += param1.dt * _loc6_.m_angularVelocity;
  160.                _loc6_._tp414();
  161.             }
  162.             _loc5_++;
  163.          }
  164.          if(param3)
  165.          {
  166.             _loc5_ = 0;
  167.             while(_loc5_ < m_jointCount)
  168.             {
  169.                _loc7_ = m_joints[_loc5_];
  170.                _loc7_._mv73();
  171.                _loc5_++;
  172.             }
  173.             m_positionIterationCount = 0;
  174.             while(m_positionIterationCount < param1.maxIterations)
  175.             {
  176.                _loc10_ = _loc8_._sl623(_kc225.b2_contactBaumgarte);
  177.                _loc11_ = true;
  178.                _loc5_ = 0;
  179.                while(_loc5_ < m_jointCount)
  180.                {
  181.                   _loc7_ = m_joints[_loc5_];
  182.                   _loc12_ = _loc7_._sl623();
  183.                   _loc11_ &&= _loc12_;
  184.                   _loc5_++;
  185.                }
  186.                if(_loc10_ && _loc11_)
  187.                {
  188.                   break;
  189.                }
  190.                ++m_positionIterationCount;
  191.             }
  192.          }
  193.          _be288(_loc8_.m_constraints);
  194.          if(param4)
  195.          {
  196.             _loc13_ = Number.MAX_VALUE;
  197.             _loc14_ = _kc225.b2_linearSleepTolerance * _kc225.b2_linearSleepTolerance;
  198.             _loc15_ = _kc225.b2_angularSleepTolerance * _kc225.b2_angularSleepTolerance;
  199.             _loc5_ = 0;
  200.             while(_loc5_ < m_bodyCount)
  201.             {
  202.                _loc6_ = m_bodies[_loc5_];
  203.                if(_loc6_.m_invMass != 0)
  204.                {
  205.                   if((_loc6_.m_flags & _th791.e_allowSleepFlag) == 0)
  206.                   {
  207.                      _loc6_.m_sleepTime = 0;
  208.                      _loc13_ = 0;
  209.                   }
  210.                   if((_loc6_.m_flags & _th791.e_allowSleepFlag) == 0 || _loc6_.m_angularVelocity * _loc6_.m_angularVelocity > _loc15_ || _ui293._qr29(_loc6_.m_linearVelocity,_loc6_.m_linearVelocity) > _loc14_)
  211.                   {
  212.                      _loc6_.m_sleepTime = 0;
  213.                      _loc13_ = 0;
  214.                   }
  215.                   else
  216.                   {
  217.                      _loc6_.m_sleepTime += param1.dt;
  218.                      _loc13_ = _ui293._ct557(_loc13_,_loc6_.m_sleepTime);
  219.                   }
  220.                }
  221.                _loc5_++;
  222.             }
  223.             if(_loc13_ >= _kc225.b2_timeToSleep)
  224.             {
  225.                _loc5_ = 0;
  226.                while(_loc5_ < m_bodyCount)
  227.                {
  228.                   _loc6_ = m_bodies[_loc5_];
  229.                   _loc6_.m_flags |= _th791.e_sleepFlag;
  230.                   _loc6_.m_linearVelocity._he34();
  231.                   _loc6_.m_angularVelocity = 0;
  232.                   _loc5_++;
  233.                }
  234.             }
  235.          }
  236.       }
  237.       
  238.       public function _pa292(param1:_th791) : void
  239.       {
  240.          var _loc2_:* = m_bodyCount++;
  241.          m_bodies[_loc2_] = param1;
  242.       }
  243.       
  244.       public function _be288(param1:Array) : void
  245.       {
  246.          var _loc2_:_oh327 = null;
  247.          var _loc3_:b2Vec2 = null;
  248.          var _loc4_:int = 0;
  249.          var _loc5_:_nb823 = null;
  250.          var _loc6_:_dm217 = null;
  251.          var _loc7_:_wf486 = null;
  252.          var _loc8_:_th791 = null;
  253.          var _loc9_:int = 0;
  254.          var _loc10_:Array = null;
  255.          var _loc11_:int = 0;
  256.          var _loc12_:_kn203 = null;
  257.          var _loc13_:int = 0;
  258.          var _loc14_:_cc280 = null;
  259.          var _loc15_:_lj358 = null;
  260.          if(m_listener == null)
  261.          {
  262.             return;
  263.          }
  264.          _loc4_ = 0;
  265.          while(_loc4_ < m_contactCount)
  266.          {
  267.             _loc5_ = m_contacts[_loc4_];
  268.             _loc6_ = param1[_loc4_];
  269.             _loc7_ = s_reportCR;
  270.             _loc7_.shape1 = _loc5_.m_shape1;
  271.             _loc7_.shape2 = _loc5_.m_shape2;
  272.             _loc8_ = _loc7_.shape1.m_body;
  273.             _loc9_ = _loc5_.m_manifoldCount;
  274.             _loc10_ = _loc5_._sg202();
  275.             _loc11_ = 0;
  276.             while(_loc11_ < _loc9_)
  277.             {
  278.                _loc12_ = _loc10_[_loc11_];
  279.                _loc7_.normal._kh737(_loc12_.normal);
  280.                _loc13_ = 0;
  281.                while(_loc13_ < _loc12_.pointCount)
  282.                {
  283.                   _loc14_ = _loc12_.points[_loc13_];
  284.                   _loc15_ = _loc6_.points[_loc13_];
  285.                   _loc7_.position = _loc8_._pj447(_loc14_.localPoint1);
  286.                   _loc7_.normalImpulse = _loc15_.normalImpulse;
  287.                   _loc7_.tangentImpulse = _loc15_.tangentImpulse;
  288.                   _loc7_.id._aw644 = _loc14_.id._aw644;
  289.                   m_listener._kx688(_loc7_);
  290.                   _loc13_++;
  291.                }
  292.                _loc11_++;
  293.             }
  294.             _loc4_++;
  295.          }
  296.       }
  297.       
  298.       public function _ti526(param1:_yw701) : void
  299.       {
  300.          var _loc2_:* = m_jointCount++;
  301.          m_joints[_loc2_] = param1;
  302.       }
  303.       
  304.       public function _hu475(param1:_nb823) : void
  305.       {
  306.          var _loc2_:* = m_contactCount++;
  307.          m_contacts[_loc2_] = param1;
  308.       }
  309.       
  310.       public function _re527() : void
  311.       {
  312.          m_bodyCount = 0;
  313.          m_contactCount = 0;
  314.          m_jointCount = 0;
  315.       }
  316.       
  317.       public function _ss251(param1:_ut97) : void
  318.       {
  319.          var _loc2_:int = 0;
  320.          var _loc3_:_kg776 = null;
  321.          var _loc4_:Number = NaN;
  322.          var _loc5_:_th791 = null;
  323.          var _loc6_:Boolean = false;
  324.          _loc3_ = new _kg776(param1,m_contacts,m_contactCount,m_allocator);
  325.          _loc2_ = 0;
  326.          while(_loc2_ < param1.maxIterations)
  327.          {
  328.             _loc3_._md397();
  329.             _loc2_++;
  330.          }
  331.          _loc2_ = 0;
  332.          while(_loc2_ < m_bodyCount)
  333.          {
  334.             _loc5_ = m_bodies[_loc2_];
  335.             if(!_loc5_._ur192())
  336.             {
  337.                _loc5_.m_sweep.c0._kh737(_loc5_.m_sweep.c);
  338.                _loc5_.m_sweep.a0 = _loc5_.m_sweep.a;
  339.                _loc5_.m_sweep.c.x += param1.dt * _loc5_.m_linearVelocity.x;
  340.                _loc5_.m_sweep.c.y += param1.dt * _loc5_.m_linearVelocity.y;
  341.                _loc5_.m_sweep.a += param1.dt * _loc5_.m_angularVelocity;
  342.                _loc5_._tp414();
  343.             }
  344.             _loc2_++;
  345.          }
  346.          _loc4_ = 0.75;
  347.          _loc2_ = 0;
  348.          while(_loc2_ < param1.maxIterations)
  349.          {
  350.             _loc6_ = _loc3_._sl623(_loc4_);
  351.             if(_loc6_)
  352.             {
  353.                break;
  354.             }
  355.             _loc2_++;
  356.          }
  357.          _be288(_loc3_.m_constraints);
  358.       }
  359.    }
  360. }
  361.  
  362.